<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="${pageContext.request.contextPath}/styly.css" type="text/css" rel="stylesheet"/>
        <title><spring:message code="res.title"/></title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
        <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
        <script>
            $(function() {
                $( "#datepicker" ).datepicker({ dateFormat: "yy-mm-dd" , minDate: new Date() ,constrainInput: false});
            });
        </script>
    </head>
    <body>
        <div class="wrapper">
            <div class="header"><h1> <spring:message code="res.title"/> </h1></div>
            <div class="navig">
                <%@ include file="../navig.jsp" %>
            </div>    

            <div class="content">
                <h3><spring:message code="res.reservations"/></h3>
                <div style="width: 60%;">
                    <h4><spring:message code="res.create"/></h4>    
                    <form method="post" action="reservationFilter">
                        <b><spring:message code="res.type"/>:</b>
                        <input type="checkbox" name="type1" value="combi">combi</input>
                        <input type="checkbox" name="type2" value="sedan">sedan</input>
                        <input type="checkbox" name="type3" value="hatchback">hatchback</input>
                        <input type="checkbox" name="type4" value="van">van</input><br/>

                        <b><spring:message code="res.seats"/>:</b>
                        <input type="checkbox" name="seats1" value="2">2</input>
                        <input type="checkbox" name="seats2" value="4">4</input>
                        <input type="checkbox" name="seats3" value="5">5</input>
                        <input type="checkbox" name="seats4" value="7">7</input><br/>

                        <input type="submit" name="filter" value="<spring:message code="res.filter"/>"  />
                        <br/><br />
                        <div style="color: green;"><spring:message code="${infoMessage}"/></div>
                    </form> 

                    <form method="post" action="reservationAdd">
                        <b><spring:message code="res.car"/>:</b> <select name="input2">
                            <c:forEach items="${cars}" var="car" >
                                <option value="${car.id}">${car.type}-${car.colour}-${car.numberOfSeats}</option>
                            </c:forEach>
                        </select><br/>
                        <b><spring:message code="res.to"/>:</b> <input type="text" name="input3" id="datepicker" /><br/>
                        <input type="submit" name="submit" value="<spring:message code="employeelist.submit"/>"  />
                        <div style="color: red;"><spring:message code="${errMessage}"/></div>
                    </form>
                    <br />
                    <table >
                        <tr class="head">
                            <td><b><spring:message code="res.employee"/></b></td>
                            <td><b><spring:message code="res.car"/></b></td>
                            <td><b><spring:message code="res.to"/></b></td>
                            <td></td>
                        </tr>
                        <c:forEach items="${reservations}" var="reservation">
                            <tr>
                                <td><c:out value="${reservation.employee.name} ${reservation.employee.surname}" /></td>
                                <td><c:out value="${reservation.car.spz}-${reservation.car.type}-${reservation.car.colour}-${reservation.car.numberOfSeats}" /></td>
                                <td><c:out value="${reservation.reservedTo}" /></td>
                                <td><a href="./reservationDelete?id=${reservation.id}"><spring:message code="res.remove"/></a></td>
                            </tr>
                        </c:forEach>   
                    </table>
                </div>    
            </div>
            <div class="footer">
                Team: Andrej Hraško, Ondřej Myška, Lukáš Slovák, Michal Polkoráb
            </div>
        </div>
    </body>
</html>